<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>  
<c:set var="ctx" value="${pageContext.request.contextPath }" />
<link rel="stylesheet"
	href="${ctx }/resources/js/select2/select2.min.css" />
<script type="text/javascript"
	src="${ctx }/resources/js/select2/select2.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/js/select2/zh-CN.js"></script>
	<script type="text/javascript">
$(function() {
	webside.form.adposition.AdpositionForm();
})
</script>
<script src="${ctx }/resources/js/upload/ajaxfileupload.js"
	type="text/javascript"></script>
  
<script type="text/javascript">
$("#code").each(function(n){
	if($(this).val()=="")
	{
	 $("#code").attr("disabled",false);
	}else{
		$("#code").attr("disabled",true);
	}
	});

</script>
<style>
.iconShow
{
	padding-left: 10px; 
	padding-top: 3px;
}
.source-icon
{
	 width:95%;
	 float:left;
}
@media screen and (max-width: 374px){
	.source-icon
	{
		 width:82%;
	}
}
@media screen and (min-width: 375px) and (max-width: 449px){
	.source-icon
	{
		 width:85%;
	}
}
@media screen and (min-width: 450px) and (max-width: 1279px) {
	.source-icon
	{
		 width:90%;
	}
}
@media screen and (min_width: 1280px) {
	.source-icon
	{
		 width:90%;
	}
}
</style>
<div class="page-header">
	<h1>
		<c:if test="${empty adposition}">
		新增广告位
		</c:if>
		<c:if test="${!empty adposition}">
		编辑广告位
		</c:if>
	</h1>
</div>
<div class="row" style="margin-top: 5px;">
	<div class="col-xs-12">
		<form id="adpositionForm" name="adpositionForm" class="form-horizontal" role="form" method="post">
			<c:if test="${!empty adposition}">
				<input type="hidden" id="pageNum" name="pageNum" value="${page.pageNum }"> 
				<input type="hidden" id="pageSize" name="pageSize" value="${page.pageSize }"> 
				<input type="hidden" id="orderByColumn" name="orderByColumn" value="${page.orderByColumn }"> 
				<input type="hidden" id="orderByType" name="orderByType" value="${page.orderByType }">
				<input type="hidden"  id='id' name="id" value="${adposition.id }">
				
			</c:if>
          
			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="name">广告位名称</label>
				<div class="col-sm-10">
				<div class="clearfix">
					<input class="form-control" name="name" id="name" type="text"
						value="${adposition.name }" placeholder="广告位名称" />
                </div>
				</div>
            </div>
              		
              <div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" 
				for="code">类型英文名</label>
				<div class="col-sm-10">
				<div class="clearfix">
				 <input class="form-control"   name="code" id="code" type="text" value="${adposition.code}" placeholder="类型英文名"
				  onKeyUp="if(this.value == ''){return false;}this.value = this.value.toUpperCase();if(!/^([_|A-Za-z]+\s?)*[_|A-Za-z]$/.test(this.value)){return this.value = this.value.substr(0, this.value.length - 1);}if(this.value.length > 10){return vthisvalue = this.value.substr(0, 9);}" 
				 />
				 <label>只能写大写字母</label>
				</div>
				</div>
             </div>
				 <input type="text" id="type" name="type" style="display:none" value="${adposition.type }"/>
	   		<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="typeName">类型</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<select id="typeName" class="form-control" name='typeName'>
						    <option typecode="" value="" <c:if test="${adposition.typeName eq null}">selected="selected"</c:if>>请选择</option>
							<c:forEach items="${pstypelist}" var="t">
							<option typecode="${t.code }" value="${t.name}"<c:if test="${adposition.typeName eq t.name}">selected="selected"</c:if>>${t.name}</option>
							</c:forEach>
						</select>
					</div>
				</div>
			</div>
	        
	       
			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="size">素材规格</label>
				<div class="col-sm-10">
				<div class="clearfix">
					<input class="form-control" name="size" id="size" type="text"
						value="${adposition.size}" placeholder="例：280*59" />
				</div>
				</div>
			</div>
			
			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="adInterval">频率/S</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="adInterval" id="adInterval" type="text"
							value="${adposition.adInterval }" placeholder="频率/S" onkeyup="value=value.replace(/[^(\d)]/g,'')" />
							<label>只能输入数字</label>
					</div>
				</div>
			</div>
			
		</form>
		<div class="hr hr-dotted"></div>
	</div>
</div>
<div class="center">
	<button id="btnAdd" type="button" 
	onclick="javascript:$('#adpositionForm').submit();" 
	class="btn btn-success btn-sm">
		<i class="fa fa-user-plus"></i>&nbsp;
		<c:if test="${empty adposition}">
		添加
		</c:if>
		<c:if test="${!empty adposition}">
		保存
		</c:if>
	</button>
	<button id="btn" type="button"
		onclick="webside.common.loadPage('/adposition/listUI.html<c:if test="${!empty adposition}">?page=${page.pageNum }&rows=${page.pageSize }&sidx=${page.orderByColumn }&sord=${page.orderByType }</c:if>')"
		class="btn btn-info btn-sm">
		<i class="fa fa-undo"></i>&nbsp;返回
	</button>
</div>
 <script type="text/javascript">
 	$("#typeName").change(function(){
 		$("#type").val($("#typeName").find("option:selected").attr("typecode"));
 	});
 </script>